package com.itheima.service.impl;

import com.fasterxml.jackson.annotation.JsonTypeInfo;

import com.itheima.aspact.RecordTimeAnno;
import com.itheima.mapper.ClazzMapper;
import com.itheima.pojo.Clazz;
import com.itheima.pojo.ClazzQueryParam;
import com.itheima.pojo.PageResult;
import com.itheima.service.ClazzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

@Service
public class ClazzServiceImpl implements ClazzService {
    @Autowired
    private  ClazzMapper clazzMapper;

    @Override
    public PageResult page(ClazzQueryParam clazzQueryParam) {
//        PageHelper.startPage(clazzQueryParam.getPage(),clazzQueryParam.getPageSize());
//
//        List<Clazz> clazzList = clazzMapper.list(clazzQueryParam);
//
//        Page<Clazz> page = (Page<Clazz>) clazzList;
//
//        return new PageResult(page.getTotal(),page.getResult());
        return null;
    }
    @RecordTimeAnno
    @Override
    public void delete(Integer id) {
        clazzMapper.delete(id);
    }
    @RecordTimeAnno
    @Override
    public void save(Clazz clazz) {
        clazz.setCreateTime(LocalDateTime.now());
        clazz.setUpdateTime(LocalDateTime.now());
        clazzMapper.save(clazz);
    }
    @RecordTimeAnno
    @Override
    public void update(Clazz clazz) {
       // clazzMapper.delete(clazz.getId());
        clazz.setUpdateTime(LocalDateTime.now());
        clazzMapper.update(clazz);
    }

    @Override
    public List<Clazz> findAll() {

        return clazzMapper.findAll();
    }

    @Override
    public Clazz getById(Integer id) {

        return clazzMapper.getById(id);
    }
}
